package com.czx.controller;

import com.alibaba.fastjson.JSON;
import com.czx.service.QueryService;
import com.czx.tools.Pages;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @package: com.czx.controller
 * @ClassName: queryController
 * @author: CZX.
 * @date: 2022/1/19 19:43
 */
@Slf4j
@Controller
public class queryController {
    @Resource
    private QueryService queryService;
    @RequestMapping("/getlist")
    public String quList(){
        return "/access/list";
    }
    @ResponseBody
    @RequestMapping(value = "/getPage")
    public String getPage(@RequestParam(defaultValue = "1", value = "pageNum") Integer pageNum,
                          @RequestParam(defaultValue = "5", value = "pageSize") Integer pageSize,
                          @RequestParam(value = "user_id", defaultValue = "0") Integer user_id) {
        log.info("pageNum=======>"+pageNum);
        log.info("pageSize=======>"+pageSize);
        log.info("user_id=======>"+user_id);
        Pages pages = queryService.getQuer(user_id,pageNum,pageSize);
        String strJson = JSON.toJSONString(pages);
        return strJson;
    }
}
